home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / AMOSList / AMOSLIST / text0132.txt < prev    next >
Encoding:
Text File  |  1998-04-01  |  1.6 KB  |  45 lines

  1. > As a substitute for select...case I don't think either is good. They're
  2. > both messy. Try this instead:
  3. > If AGE<10
  4. >    Print "You are less than 10 years old."
  5. > else if AGE=21
  6. >    Print "Hey!! Now you can drink alcohol in the U.S.!!"
  7. > else
  8. >    Print "WOW, you're OVER 21!!"
  9. > endif
  10. > Smallest, and tidiest in my humble opinion.
  11. > Is my approach good enough in the meantime?
  12.  
  13.    Well, problem is this won't work. First, you need to match every
  14.    If with an End If and second, the logic is not the same.  To write
  15.    it in the above style, so it will work in AMOS while retaining the
  16.    original logic, you'd need to do something like this:
  17. If AGE<10
  18.    Print "You are less than 10 years old."
  19. Else If AGE=21
  20.       Print"Hey!! Now you can drink alcohol in the U.S.!!"
  21.    Else If AGE>21
  22.          Print "WOW, you'r OVER 21!!"
  23.       End If
  24.    End If
  25. End If
  26.  
  27.    That being said, this might be a bit clearer (arguably the "best"
  28.    method for AMOS) but it still lacks when compared to the
  29.    Select...Case style.  Anyway, the point is you are still looking at
  30.    the same two basic methods, the If...End If and the If...Else...EndIf
  31.  
  32.  
  33. > Hey, even old GFA-BASIC had select...case. It's quite handy at
  34. > times since you could have like this for instance...
  35.  
  36.    You don't have to convince me, I agree with you (I'm a bit of a
  37.    nut for "clean" code). If there's enough interest, when Pietro has
  38.    everything sorted out, perhaps he'll implement Select...Case in
  39.    AMOS version 3.0 :-)
  40.  
  41.  
  42.                 Garfield Benjamin    e-mail:gbenjam@sosbbs.com
  43.         Website( http://www.sosbbs.com/~gbenjam ): 50% Complete
  44.  
  45.